﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EIS_desktop
{
    public partial class PayRoll : Form
    {
        private string _month,_name;
       public static double _balance;
        private int _year;
        
        public PayRoll()
        {
            InitializeComponent();
        }
        public PayRoll(string month,int year,string name,float  balance)
        {
            InitializeComponent();
            _name = name;
            txtBalance.Text = balance.ToString();

        }
        public void AddToBalance(double totalexp)
        {
            txtBalance.Text = (Convert.ToDouble(txtBalance.Text)- totalexp).ToString();
        }

        void txtBalance_TextChanged(object sender, EventArgs e)
        {
            txtBalance.Text = (Convert.ToDouble(txtBalance.Text) + _balance).ToString();
        }
        private void PayRoll_Load(object sender, EventArgs e)
        {
            txtName.Text = _name;
            if (txtRate.Text !=string.Empty & txtPercent.Text !=string.Empty)
            txtPaidRate.Text =(Convert.ToInt32(txtRate.Text)*Convert.ToInt32(txtPercent.Text)).ToString();
            if (txtPaidRate.Text!=string.Empty & txttotalhrs.Text !=string.Empty)
            txtTotalPayInvoice.Text=(Convert.ToDouble(txtPaidRate.Text)*Convert.ToInt32(txttotalhrs.Text)).ToString();
            if (txtPaidHrs.Text!=string.Empty & txtPaidRate.Text !=string.Empty)
            txtPaidAmount.Text=(Convert.ToInt32(txtPaidHrs.Text)*Convert.ToDouble(txtPaidRate.Text)).ToString();
            if (txtPaidAmount.Text !=string.Empty & txtOtherPay.Text != string.Empty  & txtDeductions.Text!=string.Empty)
            txtTotalPayRoll.Text=(Convert.ToDouble(txtPaidAmount.Text)+Convert.ToDouble(txtOtherPay.Text)-Convert.ToDouble(txtDeductions.Text)).ToString();
            if (txtTotalPayInvoice.Text != string.Empty  & txtDeductions.Text != string.Empty)
            txtBalance.Text = (Convert.ToDouble(txtTotalPayInvoice.Text) - Convert.ToDouble(txtDeductions.Text)).ToString();
        }

        private void expensesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Expenses objexpenses = new Expenses(this);
            objexpenses.Show();
           
        }

        private void btnHistory_Click(object sender, EventArgs e)
        {
            BalanceHistory objBalanceHistory = new BalanceHistory();
            objBalanceHistory.Show();
        }
    }
}
